package boot.service.impl;

import boot.domain.Supplier;
import boot.dao.SupplierDao;
import boot.domain.User;
import boot.service.ISupplierService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author enthalpy
 * @since 2022-10-28
 */
@Service
public class SupplierServiceImpl extends ServiceImpl<SupplierDao, Supplier> implements ISupplierService {
    @Autowired
    SupplierDao supplierDao;

    @Cacheable(cacheNames = "supplier",key = "#id")
    public Supplier getSupplier(int id){
        return this.getById(id);
    }

    @CacheEvict(cacheNames = "supplier",key = "#id")
    public boolean deleteSupplier(int id) {
        return this.removeById(id);
    }

    @CacheEvict(cacheNames = "supplier",key = "#id")
    public boolean updateSupplier(int id, Supplier supplier) {
        return this.saveOrUpdate(supplier);
    }
}
